﻿
<!DOCTYPE HTML>
<html>

<head>
	<meta charset="UTF-8">
	<title>后台管理系统</title>
	<link rel="stylesheet" type="text/css" href="/lib/layui/css/layui.css" />
	<script type="text/javascript" src="/lib/layui/layui.all.js" media="all"></script>
	<script src="/lib/layui/layui.js" type="text/javascript"></script>
	<script type="text/javascript" src="/lib/jquery/1.9.1/jquery.min.js"></script>
</head>
<!-------------------------------编辑删除--------------------------------->
<script type="text/html" id="barDemo">
<a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">删除</a>
<a class="layui-btn layui-btn-xs" lay-event="ckzd">用户账单</a>
<a class="layui-btn layui-btn-xs" lay-event="xq">详情</a>
<a class="layui-btn layui-btn-xs layui-btn-danger"   lay-event="dj">冻结</a>
<a class="layui-btn layui-btn-xs" lay-event="jd">解冻</a>
</script>
<body>
<table id="demo" lay-filter="test"></table>


<!-------------------------------申请推广员状态------------------------------->
<script type="text/html" id="gkUsExtensionState">
	{{#  if(d.gkUsExtensionState ==1){ }}
	<i class="layui-icon" style="color:#41B9FF;font-size: 15px">未申请</i>
	{{#  }}}
	{{#  if(d.gkUsExtensionState ==2){ }}
	<i class="layui-icon" style="color:#41B9FF;font-size: 15px">申请中</i>
	{{#  }}}
	{{#  if(d.gkUsExtensionState ==3){ }}
	<i class="layui-icon" style="color:#41B9FF;font-size: 15px">通过</i>
	{{#  }}}
	{{#  if(d.gkUsExtensionState ==4){ }}
	<i class="layui-icon" style="color:#41B9FF;font-size: 15px">未通过</i>
	{{#  }}}
</script>


<script type="text/javascript">
	layui.use(['table','layer'], function () {
		var table = layui.table;
        var layer = layui.layer;
		//第一个实例
		table.render({
			height: 'full-80',
			elem: '#demo'
			, url: '/backstage/selectALUsers' //数据接口
			, method: 'post'
			,toolbar:true
			,page: { //支持传入 laypage 组件的所有参数（某些参数除外，如：jump/elem） - 详见文档
				layout: ['limit', 'count', 'prev', 'page', 'next', 'skip'] //自定义分页布局
				//,curr: 5 //设定初始在第 5 页
				,groups: 1 //只显示 1 个连续页码
				,first: false //不显示首页
				,last: false //不显示尾页
			},
			limits:[10000,20000],
			cols: [[
				{ type:'numbers',width: 80, title: '序号'},
				{ field: 'userPhone',width: 80, title: '手机号', sort: true },
				{ field: 'userNickname',width: 80, title: '昵称', sort: true ,event: 'content'},
				{ field: 'userInvitatCode',width: 100, title: '用户推广码', sort: true },
				{ field: 'userVipStartTime', title: '会员开始日期', sort: true },
				{ field: 'userVipEndTime', title: '会员结束日期', sort: true },
                {title:'操作', toolbar: '#barDemo', width:150,fixed: 'right'},
			]],
			done: function () {
				$("[data-field='gkUserId']").css('display','none');
			}
		});


        //监听行工具事件
        table.on('tool(test)', function(obj){
            var data = obj.data;
            console.log(obj)
            if(obj.event === 'del'){
                layer.confirm('确认删除么', function(index){
                    $.post("/backstage/updateCyAgreement",
                        {"id":data.cyAgreementId},
                        function (result) {
                        if (result.status==200){
                            layer.msg("删除成功！",{icon: 6,time:1500,end:function() {
                                }
                            });
                        }
                    });
                    obj.del();
                    layer.close(index);
                });
            } else if(obj.event === 'edit'){
                layer.prompt({
                    formType: 2
                    ,value: data.email
                }, function(value, index){
                    obj.update({
                        email: value
                    });
                    layer.close(index);
                });
            }else if(obj.event === 'content'){
            	/**
				layer.open({
					type: 1
					,offset: 'auto'
					,id: 'layerDemo' //防止重复弹出
					,area: '80'
					,content: '<div ><p>'+ data.cyRaContent +'</p></div>'
					,btn: '关闭全部'
					,btnAlign: 'c' //按钮居中
					,shade: 0 //不显示遮罩
					,yes: function(){
						layer.closeAll();
					}
				});**/
			}else if(obj.event === 'ckzd'){
				location.href = '/user/yonghu-caiwu-list?gkUserId='+data.gkUserId
			}else if(obj.event === 'xq'){

                //查询评价
                layer.open({
                    type: 2,
                    skin: 'layui-layer-demo', //样式类名
                    title: '评价内容',
                    anim: 2,
                    area: ['70%', '70%'],
                    shadeClose: true, //开启遮罩关闭
                    content: '/user/yonghu-xq?gkUserId='+data.gkUserId, //这里content是一个URL，如果你不想让iframe出现滚动条，你还可以content: ['http://sentsin.com', 'no']
                });
            }else if(obj.event === 'dj'){
                $.post("/user/updateGkUserDj",{gkUserId:data.gkUserId,gkUsIsFreezeu:1},function (result) {

                    if (result.status==200){
                        layer.msg("操作成功！",{icon: 6,time:1500,end:function() {
                                location.href = '/user/yonghu-list'
                            }
                        });
                    }
                });
            }else if(obj.event === 'jd'){
                $.post("/user/updateGkUserDj",{gkUserId:data.gkUserId,gkUsIsFreezeu:2},function (result) {

                    if (result.status==200){
                        layer.msg("操作成功！",{icon: 6,time:1500,end:function() {
                                location.href = '/user/yonghu-list'
                            }
                        });
                    }
                });
            }
        });
	});

</script>
</body>
</html>